package com.example.controller;

import com.example.domain.ResponseResult;
import com.example.domain.entity.User;
import com.example.domain.vo.SystemVo;
import com.example.service.SystemService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hlc
 * @version 1.0
 * @date 2022/10/14 13:31
 */
@RestController
@RequestMapping("/system")
public class SystemController {
    private final SystemService systemService;

    public SystemController(SystemService systemService) {
        this.systemService = systemService;
    }

    @PostMapping("/login")
    public ResponseResult<SystemVo> login(@RequestBody User user) {
        return systemService.login(user);
    }

    @PostMapping("/register")
    public ResponseResult<?> register(@RequestBody User user) {
        return systemService.register(user);
    }

    @PostMapping("/sendRegisterCode")
    public ResponseResult<?> sendRegisterCode(@RequestBody User user) {
        return systemService.sendRegisterCode(user);
    }

    @PostMapping("/forget")
    public ResponseResult<?> forget(@RequestBody User user) {
        return systemService.forget(user);
    }

    @PostMapping("/sendCheckCode")
    public ResponseResult<?> sendCheckCode(@RequestBody User user) {
        return systemService.sendCheckCode(user);
    }
}
